package com.synjones.zeuscloudweb.controller;

import com.synjones.zeus.model.web.MenuBean;
import com.synjones.zeuscloudweb.service.MenuService;
import com.synjones.zeuscloudweb.util.ccl.datastructure.impl.BaseDto;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 菜单管理
 * @author  yys
 * Description: 菜单管理
 * @date  created in 15:18 2018-01-17
 * Modified by:
 */
@RequestMapping("/menu")
@Controller
public class MenuController {
    @Autowired
    @Qualifier("menuServiceImpl")
    private MenuService menuService;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
 /**
   *  菜单管理页跳转
   *  @param 
   *  @author yys
   *  Description:  菜单管理页跳转
   *  @date  15:21 2018-01-17
   *  @return  String
   *  throws
   */
    @RequestMapping(value = "/menuListInfo" , method = RequestMethod.GET)
    public String menuListInfo(){
        return "menu-list";
    }
    /**
     * 添加菜单页面跳转
     * @param Id 菜单Id
     * @author yys
     * description:  添加用户页面跳转
     * @date  15:02 2018-01-08
     * return:
     */
    @RequestMapping(value = "/addMenuInfo", method = RequestMethod.GET)
    public String addMenuInfo(Model model , @Param("Id")String Id) {
        model.addAttribute("Id",Id);
        return "menu-add";
    }

    /**
     * 添加菜单
     * @param menuBean 菜单
     * @author yys
     * description:  添加菜单
     * @date  15:02 2018-01-08
     * return:
     */
    @RequestMapping(value = "/addMenu", method = RequestMethod.POST)
    @ResponseBody
    public BaseDto addMenu(MenuBean menuBean) {
        return menuService.insertMenu(menuBean);
    }
    /**
     * 修改菜单页面跳转
     * @param Id 菜单Id
     * @author yys
     * description:  修改菜单页面跳转
     * @date  15:02 2018-01-08
     * return:
     */
    @RequestMapping(value = "/updateMenuInfo", method = RequestMethod.GET)
    public String updateMenuInfo(Model model , @Param("Id")String Id) {
        MenuBean menuBean = menuService.selectMenu(Id);
        model.addAttribute("menuBean",menuBean);
        return "menu-update";
    }
    /**
     * 修改菜单
     * @param menuBean 菜单
     * @author yys
     * description:  修改菜单
     * @date  15:02 2018-01-08
     * return:
     */
    @RequestMapping(value = "/updateMenu", method = RequestMethod.POST)
    @ResponseBody
    public BaseDto updateMenu(MenuBean menuBean) {
        return menuService.updateMenu(menuBean);
    }
  /**
   * 删除菜单
   * @param Id 菜单Id
   * @author yys
   * description:  删除菜单
   * @date  15:02 2018-01-08
   * return: BaseDto
   */
    @RequestMapping(value = "/deleteMenuById", method = RequestMethod.POST)
    @ResponseBody
    public BaseDto deleteMenuById(@Param("Id")String Id) {
        return menuService.deleteMenuById(Id);
    }

}
